# -*- coding: utf-8 -*-
# -*- frozen_string_literal: true -*-

require "rake/testtask"
require "rdoc/task"
require "nowadays/manifest"
require "nowadays/doc"

# only add tasks that are useful for anyone who `gem install nowadays --development`
# tasks meant for maintainers go in `./dev/tasks/`.
FileList["dev/tasks/*.rake"].each(&method(:import)) if Dir.exist? "./dev/tasks"

task :default => :test

Rake::TestTask.new(:test) do |t|
  ENV["NOWADAYS_ALL_TESTS"] = "1"
  test_dev = "test/dev"

  t.libs.<<(*Nowadays::Manifest.codebase).<<(Nowadays::Manifest.test_suite)
  tests =  Nowadays::Manifest.tests
  tests = tests.dup.<<(FileList["#{test_dev}/**/test_*.rb"]) if Dir.exist? test_dev
  t.test_files = tests
  t.warning = true
end

RDoc::Task.new(rdoc: "doc:build", clobber_rdoc: "doc:remove", rerdoc: "doc:rebuild") do |d|
  d.generator = "hanna"
  d.rdoc_dir = "doc"
  d.rdoc_files.include(*Nowadays::Doc.files).include(*Nowadays::Doc.appendices)
  d.options = Nowadays::Doc.build_options
end
